package ru.ognick.coachsystem.common;

import java.io.Serializable;

public class Time implements Serializable{
	private static final long serialVersionUID = 6700449789066473073L;
	
	private int min;
	private int sec;
	
	public Time(int min, int sec){
		setMin(min);
		setSec(sec);
	}
	
	public String toString(){
		return (
			((min < 10)? "0" + min : String.valueOf(min)) + ":" +
			((sec < 10)? "0" + sec : String.valueOf(sec))       );
	}
	
	
	public long toMilliSeconds(){
		return toSeconds() * 1000;
	}
	
	public long toSeconds(){
		return (min*60 + sec);
	}
	
	public static Time ofMilliSeconds(float ms){
		return ofSeconds((int) (ms / 1000));
	}
	
	public static Time ofSeconds(int sec){
		return new Time(sec / 60, sec % 60);
	}
	
	public void setMin(int min) {
		this.min = min;
	}
	public int getMin() {
		return min;
	}
	
	public void setSec(int sec) {
		this.sec = sec;
	}
	public int getSec() {
		return sec;
	}

}
